<?php

class Core_Model_User extends App_Db_Table
{
    protected $_name = 'core_user';
    protected $_primary = 'user_pid';

    /**
     * Return user for current identity
     * @param string $identity
     * @return Zend_Db_Table_Row
     */
    public function login($identity)
    {
        $where = $this->select()->where('identity = ?', $identity);
        $user = $this->fetchRow($where);
        if (!$user) {
            $user = $this->createRow();
            $user->identity = $identity;
            $user->save();
        }
        return $user;
    }
}